-- 10.24.14
-- main.lua

class = require'lib.middleclass.trunk.middleclass'
Stateful = require'lib.stateful.trunk.stateful'
lume = require'lib.lume.trunk.lume'
JSON = require'lib.JSON'
require'lib.AnAL'
require'lib.loveframes.trunk'
require'src.game'

function love.load()
    game = Game:new()
    load_images()
end

function load_images()
    image = {}
    image.floor_tile = love.graphics.newImage("img/dead_skies_128.jpg")
    image.wall_tile = love.graphics.newImage("img/Remaining_Light_128.jpg")
end

function love.update(dt)
	dt = math.min(0.01666667, dt)
	game:update(dt)
	loveframes.update(dt)
end

function love.draw()
	game:draw()
	loveframes.draw()
end

function love.keypressed(key, isRepeat)
	game:keypressed(key, isRepeat)
	loveframes.keypressed(key, isRepeat)
end

function love.keypreleased(key)
	game:keyreleased(key)
	loveframes.keyreleased(key)
end

function love.mousepressed(x, y, button)
	game:mousepressed(x, y, button)
	loveframes.mousepressed(x, y, button)
end

function love.mousereleased(x, y, button)	
	game:mousereleased(x, y, button)
	loveframes.mousereleased(x, y, button)
end

function love.focus(f)
    
end

function love.textinput(text)
	loveframes.textinput(text)
end

function love.threaderror(thread, errorstr)
	print("Thread Error!\n" .. errorstr)
end

function love.quit()
	game:quit()
end